/*
 * Copyright 2000-2018. YGSoft.Inc All Rights Reserved.
 */

package com.wn.budget.code.context;

import java.util.HashMap;
import java.util.Map;

/**
 * 上下文访问类
 * 每个可复用属性需要的状态属性，都应该在这里定义g/s方法，尽量避免通过k/v访问
 */
public class Context implements LoginUserProperty, SecurityProperty, MultiTenantProperty, RequestProperty {

    private final Map<String, Object> contextRepository = new HashMap<>();

    @Override
    public Map<String, Object> getRepository() {
        return contextRepository;
    }

    @Override
    public String toString() {
        StringBuilder ret = new StringBuilder();
        ret.append("{");
        contextRepository.forEach((k, v) -> ret.append(String.format("\n\t%s = %s", k, v)));
        ret.append("\n}");
        return ret.toString();
    }

}
